package com.cskaoyan.mall.commons.util;

import com.alibaba.fastjson.JSON;
import com.cskaoyan.mall.commons.result.UserLoginMsg;
import com.cskaoyan.mall.commons.util.jwt.JwtTokenUtils;

import javax.servlet.http.HttpServletRequest;

/**
 * @author kefei
 * @description: 获取登陆中的用户的信息
 * @date 2023/1/10 16:23
 */
public class GetUserInfoUtils {

    public static UserLoginMsg getUserInfo(HttpServletRequest request){

        String token = CookieUtil.getCookieValue(request, "access_token");
        String json = JwtTokenUtils.builder().token(token).build().freeJwt();
        UserLoginMsg userLoginMsg = JSON.parseObject(json, UserLoginMsg.class);

        return userLoginMsg;
    }

}
